<template>
  <div class="app-container">
    <customerApp ref="customerApp"></customerApp>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户编号" prop="customerNo">
        <el-input
          v-model="queryParams.customerNo"
          placeholder="请输入"
          @keyup.enter.native="handleQuery"
        ></el-input>
      </el-form-item>
      <el-form-item label="联系电话" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入"
          @keyup.enter.native="handleQuery"
        ></el-input>
      </el-form-item>
      <el-form-item label="审批状态" prop="auditStatus">
        <el-select
          v-model="queryParams.auditStatus"
          placeholder="请选择"
          clearable
        >
          <el-option
            v-for="dict in dict.type.approval_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table ref="tables" v-loading="loading" :data="list" :height="tableHeight">
      <el-table-column label="客户编号" align="center" :show-overflow-tooltip="true" width="130" prop="customerNo" />
      <el-table-column label="客户名称" align="center" :show-overflow-tooltip="true" width="160" prop="customerName" />
      <el-table-column label="客户分类" align="center" :show-overflow-tooltip="true" prop="categoryName" />
      <el-table-column label="客户状态" align="center" prop="state" width="150" :show-overflow-tooltip="true">
        <template slot-scope="scope" >
          <dict-tag
            :options="dict.type.customer_state"
            :value="scope.row.state"
          />
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center" prop="mobile" width="150" :show-overflow-tooltip="true"/>
      <el-table-column label="登记人" align="center" prop="createBy" width="150" :show-overflow-tooltip="true"/>
      <el-table-column label="审批状态" align="center" prop="auditStatus" width="80" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.approval_status"
            :value="scope.row.auditStatus"
          />
        </template>
      </el-table-column>
      <!-- <el-table-column label="登录日期" align="center" prop="loginTime">
                <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.loginTime) }}</span>
                </template>
            </el-table-column> -->
      <el-table-column label="操作" align="center" prop="loginTime" width="180" fixed="right">
        <template slot-scope="scope">
          <template v-if="scope.row.auditStatus == '0'">
            <el-button
              size="mini"
              type="text"
              @click="onShow(scope.row, 2)"
              v-hasPermi="['approval:customer:pass']"
              >审批</el-button
            >
            <!-- <el-button
                            size="mini"
                            type="text"
                            style="color: red"
                            @click="onShow(0)"
                            v-hasPermi="['approval:reserve:refuse']"
                            >拒绝</el-button
                        >
                         -->
          </template>
          <span
            v-else
            @click="onShow(scope.row, 3)"
            style="color: #1890ff; font-size: 12px"
            >查看</span
          >
          <!-- <span style="color: #1890ff;font-size: 12px;" v-if="scope.row.auditStatus == '1'">
                        已通过
                    </span>
                    <span style="color: red;font-size: 12px;" v-if="scope.row.auditStatus == '2'">
                        已拒绝
                    </span> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <detailModal ref="detailModal"></detailModal>
  </div>
</template>

<script>
import { list } from "@/api/approval/customer.js";
import customerApp from "./customerApp.vue";
import detailModal from "@/views/customer/detailModal.vue";
export default {
  data() {
    return {
      queryParams: {
        mobile: "",
        reserveName: "",
        auditStatus: "",
        customerNo: "", // 客户编号
        useDate: "",
        auditor: 1,
        pageNum: 1,
        pageSize: 10,
        orderByColumn:'updateTime',
        isAsc: 'desc',
        // orderByColumn:'auditStatus',
        // isAsc: 'asc',
      },
      list: [],
      loading: false,
      total: 0,
      dialogVisible: false,
      passParams: {
        type: 0,
        reasion: "",
      },
    };
  },
  dicts: ["approval_status", "customer_state"],
  components: {
    customerApp,
    detailModal,
  },
  computed:{
    tableHeight () {
      return this.$store.state.app.clientHeight
    }
  },
  methods: {
    /** 拒接或者通过 */
    onSure() {
      this.dialogVisible = false;
      this.getList();
    },
    onShow(row, islook) {
      // this.dialogVisible = true
      // this.passParams.type = type
      this.$refs.detailModal.open(row, islook);
    },
    /** 查询菜单列表 */
    getList() {
      this.loading = true;
      // this.queryParams.auditStatus = +this.queryParams.auditStatus
      list(this.queryParams).then((res) => {
        this.list = res.rows;
        this.total = res.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
  mounted() {
    this.getList();
  },
};
</script>

<style></style>
